package com.base.action;

import java.util.Date;
import java.util.List;
import java.util.Set;

import com.base.bean.Cardinfo;
import com.base.service.CardinfoService;
import com.base.service.FlowaudithistoryService;
import com.base.service.PermissionService;
import com.common.bean.Cardsubtype;
import com.common.bean.Datadict;
import com.common.bean.Department;
import com.common.bean.Flowaudithistory;
import com.common.bean.Flowtemplatebranch;
import com.common.bean.Flowtemplatedetail;
import com.common.bean.Flowworkitem;
import com.common.bean.Personnel;
import com.common.bean.Rule;
import com.common.util.PagerModel;
import com.common.util.StringToken;
import com.core.ssh2.AbstractActionSupport;
import com.opensymphony.xwork2.Preparable;
import com.workflow.bean.Applydept;
import com.workflow.bean.Applydeptdetail;
import com.workflow.bean.Exitcard;
import com.workflow.bean.Exitdept;
import com.workflow.bean.Exitdeptdetail;
import com.workflow.bean.Inputcard;
import com.workflow.bean.Inputdept;
import com.workflow.bean.Inputdeptdetail;
import com.workflow.bean.Outputcard;
import com.workflow.bean.Outputdept;
import com.workflow.bean.Outputdeptdetail;
import com.workflow.bean.Salescard;
import com.workflow.bean.Salesdept;
import com.workflow.bean.Salesdeptdetail;
import com.workflow.service.ApplydeptService;
import com.workflow.service.ApplydeptdetailService;
import com.workflow.service.ExitcardService;
import com.workflow.service.ExitdeptService;
import com.workflow.service.ExitdeptdetailService;
import com.workflow.service.InputcardService;
import com.workflow.service.InputdeptService;
import com.workflow.service.InputdeptdetailService;
import com.workflow.service.OutputcardService;
import com.workflow.service.OutputdeptService;
import com.workflow.service.OutputdeptdetailService;
import com.workflow.service.SalescardService;
import com.workflow.service.SalesdeptService;
import com.workflow.service.SalesdeptdetailService;

public class FlowaudithistoryManagerAction extends AbstractActionSupport
		implements Preparable {
	private static final long serialVersionUID = -271870153785901757L;

	private FlowaudithistoryService flowaudithistoryService;
	
	private ApplydeptService applydeptService;
	
	private ApplydeptdetailService applydeptdetailService;
	
	private OutputdeptService outputdeptService;
	
	private OutputdeptdetailService outputdeptdetailService;
	
	private OutputcardService outputcardService;
	
	private InputdeptService inputdeptService;
	
	private InputdeptdetailService inputdeptdetailService;
	
	private InputcardService inputcardService;
	
	private ExitdeptService exitdeptService;
	
	private ExitdeptdetailService exitdeptdetailService;
	
	private ExitcardService exitcardService;
	
	private SalesdeptService salesdeptService;
	
	private SalesdeptdetailService salesdeptdetailService;
	
	private SalescardService salescardService;
	
	private Flowaudithistory flowaudithistory; 
	
	private PermissionService permissionService;
	
	private CardinfoService cardinfoService;
	
	private String flowid;
	
	private PagerModel pm;
	
	private long flowflag;
	
	private String flowno;//主单编号
	
	private String dictbranch;//分支标识
	
	private String branchno;//分支编号
	
	private String result;//审核结果
	
	Flowworkitem flowworkitem;
	
	public void prepare() throws Exception {
	}

	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}
	
	@SuppressWarnings("unchecked")
	public String addFlowaudithistory() throws Exception {
		Personnel personnel = (Personnel) this.getSession().get(StringToken.CURRENT_LOGIN);
		if(personnel == null) {
			throw new RuntimeException("请重新登陆！");
		}
		Department department = personnel.getDepartment();//操作人所在部门
		Flowtemplatedetail flowtemplatedetail = null;
		Flowtemplatebranch flowtemplatebranch = null;
		
		Applydept applydept = null;
		Outputdept outputdept = null;
		Inputdept inputdept = null;
		Exitdept exitdept = null;
		Salesdept salesdept = null;//
		
		Applydeptdetail applydeptdetail = null;
		Outputdeptdetail outputdeptdetail = null;
		Inputdeptdetail inputdeptdetail = null;
		Exitdeptdetail exitdeptdetail = null;
		Salesdeptdetail salesdeptdetail = null;//
		
		Datadict datadict = null;//当前状态
		Datadict datadictByBranch = null;//分支状态
		Rule rule = null;//相应步骤所需角色
		boolean checked = false;
		Object permission = null;
		long st = 0l;//起始时间
		long lt = 0l;//限制时间
		
		Datadict datadictByResultno = new Datadict();
		Datadict datadictByStatus = null;//通过后应置状态
		
		if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {//flowflag由页面传进
			applydept = applydeptService.findApplydept(flowno);
			flowworkitem = applydept.getFlowworkitem();//获得与单子对应的模版
			flowtemplatedetail = applydept.getFlowtemplatedetail();
			datadict = applydept.getDatadictByStatus();
			datadictByBranch = applydept.getDatadictByBranch();
			st = applydept.getStartdate().getTime();
			lt = applydept.getLimitday();
			
			if(StringToken.DICT_FLOWBRANCH_YES.equals(dictbranch)) {
				applydeptdetail = applydeptdetailService.findApplydeptdetail(branchno);
				flowtemplatebranch = applydeptdetail.getFlowtemplatebranch();
			}
			checked = true;//是否获得相关实例
		}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
			outputdept = outputdeptService.findOutputdept(flowno);
			flowworkitem = outputdept.getFlowworkitem();
			flowtemplatedetail = outputdept.getFlowtemplatedetail();
			datadict = outputdept.getDatadictByStatus();
			datadictByBranch = outputdept.getDatadictByBranch();
			st = outputdept.getStartdate().getTime();
			lt = outputdept.getLimitday();
			
			if(StringToken.DICT_FLOWBRANCH_YES.equals(dictbranch)) {
				outputdeptdetail = outputdeptdetailService.findOutputdeptdetail(branchno);
				flowtemplatebranch = outputdeptdetail.getFlowtemplatebranch();
			}
			checked = true;
		}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
			inputdept = inputdeptService.findInputdept(flowno);
			flowworkitem = inputdept.getFlowworkitem();
			flowtemplatedetail = inputdept.getFlowtemplatedetail();
			datadict = inputdept.getDatadictByStatus();
			datadictByBranch = inputdept.getDatadictByBranch();
			st = inputdept.getStartdate().getTime();
			lt = inputdept.getLimitday();
			
			if(StringToken.DICT_FLOWBRANCH_YES.equals(dictbranch)) {
				inputdeptdetail = inputdeptdetailService.findInputdeptdetail(branchno);
				flowtemplatebranch = inputdeptdetail.getFlowtemplatebranch();
			}
			checked = true;
		}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
			exitdept = exitdeptService.findExitdept(flowno);
			flowworkitem = exitdept.getFlowworkitem();
			flowtemplatedetail = exitdept.getFlowtemplatedetail();
			datadict = exitdept.getDatadictByStatus();
			datadictByBranch = exitdept.getDatadictByBranch();
			st = exitdept.getStartdate().getTime();
			lt = exitdept.getLimitday();
			
			if(StringToken.DICT_FLOWBRANCH_YES.equals(dictbranch)) {
				exitdeptdetail = exitdeptdetailService.findExitdetailno(branchno);
				flowtemplatebranch = exitdeptdetail.getFlowtemplatebranch();
			}
			checked = true;
		}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
			salesdept = salesdeptService.findSalesdept(flowno);
			flowworkitem = salesdept.getFlowworkitem();
			flowtemplatedetail = salesdept.getFlowtemplatedetail();
			datadict = salesdept.getDatadictByStatus();
			datadictByBranch = salesdept.getDatadictByBranch();
			st = salesdept.getStartdate().getTime();
			lt = salesdept.getLimitday();
			
			if(StringToken.DICT_FLOWBRANCH_YES.equals(dictbranch)) {
				salesdeptdetail = salesdeptdetailService.findSalesdeptdetail(branchno);
				flowtemplatebranch = salesdeptdetail.getFlowtemplatebranch();
			}
			checked = true;
		}
		
		long nt = new Date().getTime();//获取当前时间
		if(lt - (nt-st)/(1000*60*60*24) < 0) { //判断是否超时 ，可修改超时状态然后正常存储转发
			throw new RuntimeException("Limitday is too small.");
		}
		
		if(checked) {
			//先看状态是否非完成、作废、过时
			if("完成".equals(datadict.getName()) || "作废".equals(datadict.getName())) {
				throw new RuntimeException("该单已过期！");
			}
			
//			获取前一步，下一步骤
			Flowtemplatedetail front = null;
			Flowtemplatedetail back = null;
			Flowtemplatedetail curr = flowtemplatedetail;
			Set<Flowtemplatedetail> set = flowworkitem.getFlowtemplatedetails();
			for(Flowtemplatedetail flow : set) {
				if(flow.getSeq() == flowtemplatedetail.getSeq() + 1){
					front = flow;
				}
				if(flow.getSeq() == flowtemplatedetail.getSeq() - 1){
					back = flow;
				}
			}
			
			if(StringToken.DICT_FLOWBRANCH_YES.equals(dictbranch)) {//改为用单子分支标识判断
				//根据单子标识处理
				if(department.getDeptcode().equals(flowtemplatebranch.getDepartment().getDeptcode())){
					rule = flowtemplatebranch.getRule();
					permission = permissionService.findPersonneltorulelink(rule.getRuleno(), personnel.getStaffcode());
				}
				
				if(permission == null && (!"admin".equals(personnel.getLoginname()))) {//TODO
					throw new RuntimeException("没有权限执行该操作。");
				}
				
				/*
				 *通过、拒绝
				 *获取：下一分支，下一主流程  若无判断其它分支是否是最大分支步骤全是，进入单子分支状态修改为该无分支
				 * 	   前一分支，前一主流程  若拒绝且所有分支都是第一步回退到主流程 单子分支状态修改为无分支
				 * 	  
				 * */
				
				Flowtemplatebranch branch_f = null;
				Flowtemplatebranch branch_b = null;
				Flowtemplatebranch branch_c = flowtemplatebranch;//当前分支
				
				for(Flowtemplatebranch bran : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()) {
					if(bran.getCardsubtype().equals(flowtemplatebranch.getCardsubtype()) && bran.getBranchseq() == flowtemplatebranch.getBranchseq() + 1) {
						branch_f = bran;
					}
					if(bran.getCardsubtype().equals(flowtemplatebranch.getCardsubtype()) && bran.getBranchseq() == flowtemplatebranch.getBranchseq() - 1) {
						branch_b = bran;
					}
				}
				
				if(StringToken.DICT_WORK_RESULT_T.equals(result)) {//通过
					datadictByStatus = flowtemplatebranch.getDatadict();
					datadictByResultno.setTypeid(StringToken.DICT_FLOWRESULT_T);
					
					if(branch_f != null){
						branch_c = branch_f;
						
						//修改当前分支的步骤
						if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {//flowflag由页面传进
							applydeptdetail.setFlowtemplatebranch(branch_c);
							applydeptdetailService.updateApplydeptdetail(applydeptdetail);
						}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
							outputdeptdetail.setFlowtemplatebranch(branch_c);
							outputdeptdetailService.updateOutputdeptdetail(outputdeptdetail);
						}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
							inputdeptdetail.setFlowtemplatebranch(branch_c);
							inputdeptdetailService.updateInputdeptdetail(inputdeptdetail);
						}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
							salesdeptdetail.setFlowtemplatebranch(branch_c);
							salesdeptdetailService.updateSalesdeptdetail(salesdeptdetail);
						}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
							exitdeptdetail.setFlowtemplatebranch(branch_c);
							exitdeptdetailService.updateExitdetailno(exitdeptdetail);
						}
					}else {//分支结束了 判断其它分支是否同样结束 如何判断有这样的审核过程所有对应的分支都通过了审核
						boolean check_all_over = true;
						Datadict branch_temp = new Datadict();
						branch_temp.setTypeid(StringToken.DICT_BRANCH_NO);
						
						if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {
							for(Applydeptdetail apd : (Set<Applydeptdetail>)applydept.getApplydeptdetails()){
								Flowtemplatebranch temp_branch = new Flowtemplatebranch();
								temp_branch.setBranchseq(1);
								for(Flowtemplatebranch flow : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()){
									//根据子卡类型 找到最大模版序号 并比较相应的分支
									if(flow.getCardsubtype().equals(apd.getCardsubtype()))
									if(flow.getBranchseq() > temp_branch.getBranchseq()) {
										temp_branch = flow;
									}
								}
								if(!apd.getFlowtemplatebranch().equals(temp_branch)) {//是否是最大分支
									check_all_over = false;
									break;
								}
							}
							
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								applydept.setFlowtemplatedetail(front);
								applydept.setDatadictByBranch(branch_temp);
								applydeptService.updateApplydept(applydept);
							}
						}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
							for(Outputdeptdetail opd : (Set<Outputdeptdetail>)outputdept.getOutputdeptdetails()){
								Flowtemplatebranch temp_branch = new Flowtemplatebranch();
								temp_branch.setBranchseq(1);
								for(Flowtemplatebranch flow : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()){
									//根据子卡类型 找到最大模版序号 并比较相应的分支
									if(flow.getCardsubtype().equals(opd.getCardsubtype()))
									if(flow.getBranchseq() > temp_branch.getBranchseq()) {
										temp_branch = flow;
									}
								}
								if(!opd.getFlowtemplatebranch().equals(temp_branch)) {//是否是最大分支
									check_all_over = false;
									break;
								}
							}
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								outputdept.setFlowtemplatedetail(front);
								outputdept.setDatadictByBranch(branch_temp);
								outputdeptService.updateOutputdept(outputdept);
							}
						}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
							for(Inputdeptdetail ipd : (Set<Inputdeptdetail>)inputdept.getInputdeptdetails()){
								Flowtemplatebranch temp_branch = new Flowtemplatebranch();
								temp_branch.setBranchseq(1);
								for(Flowtemplatebranch flow : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()){
									//根据子卡类型 找到最大模版序号 并比较相应的分支
									if(flow.getCardsubtype().equals(ipd.getCardsubtype()))
									if(flow.getBranchseq() > temp_branch.getBranchseq()) {
										temp_branch = flow;
									}
								}
								if(!ipd.getFlowtemplatebranch().equals(temp_branch)) {//是否是最大分支
									check_all_over = false;
									break;
								}
							}
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								inputdept.setFlowtemplatedetail(front);
								inputdept.setDatadictByBranch(branch_temp);
								inputdeptService.updateInputdept(inputdept);
							}
						}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
							for(Exitdeptdetail epd : (Set<Exitdeptdetail>)exitdept.getExitdeptdetails()){
								Flowtemplatebranch temp_branch = new Flowtemplatebranch();
								temp_branch.setBranchseq(1);
								for(Flowtemplatebranch flow : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()){
									//根据子卡类型 找到最大模版序号 并比较相应的分支
									if(flow.getCardsubtype().equals(epd.getCardsubtype()))
									if(flow.getBranchseq() > temp_branch.getBranchseq()) {
										temp_branch = flow;
									}
								}
								if(!epd.getFlowtemplatebranch().equals(temp_branch)) {//是否是最大分支
									check_all_over = false;
									break;
								}
							}
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								exitdept.setFlowtemplatedetail(front);
								exitdept.setDatadictByBranch(branch_temp);
								exitdeptService.updateExitdept(exitdept);
							}
						}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
							for(Salesdeptdetail spd : (Set<Salesdeptdetail>)salesdept.getSalesdeptdetails()){
								Flowtemplatebranch temp_branch = new Flowtemplatebranch();
								temp_branch.setBranchseq(1);
								for(Flowtemplatebranch flow : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()){
									//根据子卡类型 找到最大模版序号 并比较相应的分支
									if(flow.getCardsubtype().equals(spd.getCardsubtype()))
									if(flow.getBranchseq() > temp_branch.getBranchseq()) {
										temp_branch = flow;
									}
								}
								if(!spd.getFlowtemplatebranch().equals(temp_branch)) {//是否是最大分支
									check_all_over = false;
									break;
								}
							}
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								salesdept.setFlowtemplatedetail(front);
								salesdept.setDatadictByBranch(branch_temp);
								salesdeptService.updateSalesdept(salesdept);
							}
						}
					}
				}else {//拒绝
					datadictByStatus = flowtemplatebranch.getDatadict();
					datadictByResultno.setTypeid(StringToken.DICT_FLOWRESULT_F);
					
					if(branch_b != null){
						branch_c = branch_b;
						
						//修改当前分支的步骤
						if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {//flowflag由页面传进
							applydeptdetail.setFlowtemplatebranch(branch_c);
							applydeptdetailService.updateApplydeptdetail(applydeptdetail);
						}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
							outputdeptdetail.setFlowtemplatebranch(branch_c);
							outputdeptdetailService.updateOutputdeptdetail(outputdeptdetail);
						}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
							inputdeptdetail.setFlowtemplatebranch(branch_c);
							inputdeptdetailService.updateInputdeptdetail(inputdeptdetail);
						}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
							salesdeptdetail.setFlowtemplatebranch(branch_c);
							salesdeptdetailService.updateSalesdeptdetail(salesdeptdetail);
						}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
							exitdeptdetail.setFlowtemplatebranch(branch_c);
							exitdeptdetailService.updateExitdetailno(exitdeptdetail);
						}
					}else {//分支结束了 判断其它分支是否同样结束 如何判断有这样的审核过程所有对应的分支都通过了审核
						boolean check_all_over = true;
						Datadict branch_temp = new Datadict();
						branch_temp.setTypeid(StringToken.DICT_BRANCH_NO);
						
						if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {
							for(Applydeptdetail apd : (Set<Applydeptdetail>)applydept.getApplydeptdetails()){
								if(apd.getFlowtemplatebranch().getBranchseq() != 1) {
									check_all_over = false;
									break;
								}
							}
							
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								applydept.setDatadictByBranch(branch_temp);
								applydeptService.updateApplydept(applydept);
							}
						}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
							for(Outputdeptdetail opd : (Set<Outputdeptdetail>)outputdept.getOutputdeptdetails()){
								if(opd.getFlowtemplatebranch().getBranchseq() != 1) {
									check_all_over = false;
									break;
								}
							}
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								outputdept.setDatadictByBranch(branch_temp);
								outputdeptService.updateOutputdept(outputdept);
							}
						}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
							for(Inputdeptdetail ipd : (Set<Inputdeptdetail>)inputdept.getInputdeptdetails()){
								if(ipd.getFlowtemplatebranch().getBranchseq() != 1) {
									check_all_over = false;
									break;
								}
							}
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								inputdept.setDatadictByBranch(branch_temp);
								inputdeptService.updateInputdept(inputdept);
							}
						}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
							for(Salesdeptdetail spd : (Set<Salesdeptdetail>)salesdept.getSalesdeptdetails()){
								if(spd.getFlowtemplatebranch().getBranchseq() != 1) {
									check_all_over = false;
									break;
								}
							}
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								salesdept.setDatadictByBranch(branch_temp);
								salesdeptService.updateSalesdept(salesdept);
							}
						}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
							for(Exitdeptdetail epd : (Set<Exitdeptdetail>)exitdept.getExitdeptdetails()){
								if(epd.getFlowtemplatebranch().getBranchseq() != 1) {
									check_all_over = false;
									break;
								}
							}
							if(check_all_over) {//全部分支结束 更改主单的分支标识 流程步骤
								exitdept.setDatadictByBranch(branch_temp);
								exitdeptService.updateExitdept(exitdept);
							}
						}
					}
				}//end result 
			}else {
				if(department.getDeptcode().equals(flowtemplatedetail.getDepartment().getDeptcode())){
					rule = flowtemplatedetail.getRule();
					permission = permissionService.findPersonneltorulelink(rule.getRuleno(), personnel.getStaffcode());
				}
				if(permission == null && (!"admin".equals(personnel.getLoginname()))) {//TODO
					throw new RuntimeException("no permission for it.");
				}
				
				if(StringToken.DICT_WORK_RESULT_T.equals(result)) {//通过
					//判断当前流程状态是否为完成
					datadictByStatus = flowtemplatedetail.getDatadictByWorkflowstatusno();
					datadictByResultno.setTypeid(StringToken.DICT_FLOWRESULT_T);
					curr = front;
					flowaudithistory.setPreseq(flowtemplatedetail.getSeq());
					
					if(StringToken.DICT_FLOWBRANCH_YES.equals(flowtemplatedetail.getDatadictByBranch().getName())) {
						curr = flowtemplatedetail;
						flowaudithistory.setPreseq(flowtemplatedetail.getSeq());
						datadictByBranch = flowtemplatedetail.getDatadictByBranch();
						
						//修改单子获取子单 修改其模版分支
						if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {//flowflag由页面传进
							applydept.setDatadictByBranch(flowtemplatedetail.getDatadictByBranch());
							//修改报领明细表模版分支
							for(Applydeptdetail detail : (Set<Applydeptdetail>)applydept.getApplydeptdetails()) {
								//根据明细子卡类型获取相应模版的分支第一步
								Cardsubtype subtype = detail.getCardsubtype();
								for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()) {
									if(subtype.equals(branch.getCardsubtype()) &&  branch.getBranchseq() == 1) {
										detail.setFlowtemplatebranch(branch);
										applydeptdetailService.updateApplydeptdetail(detail);
									}
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
							outputdept.setDatadictByBranch(flowtemplatedetail.getDatadictByBranch());
//								修改出库明细表模版分支
							for(Outputdeptdetail detail : (Set<Outputdeptdetail>)outputdept.getOutputdeptdetails()) {
								//根据明细子卡类型获取相应模版的分支第一步
								Cardsubtype subtype = detail.getCardsubtype();
								for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()) {
									if(subtype.equals(branch.getCardsubtype()) &&  branch.getBranchseq() == 1) {
										detail.setFlowtemplatebranch(branch);
										outputdeptdetailService.updateOutputdeptdetail(detail);
									}
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
							inputdept.setDatadictByBranch(flowtemplatedetail.getDatadictByBranch());
//								修改入库明细表模版分支
							for(Inputdeptdetail detail : (Set<Inputdeptdetail>)inputdept.getInputdeptdetails()) {
								//根据明细子卡类型获取相应模版的分支第一步
								Cardsubtype subtype = detail.getCardsubtype();
								for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()) {
									if(subtype.equals(branch.getCardsubtype()) &&  branch.getBranchseq() == 1) {
										detail.setFlowtemplatebranch(branch);
										inputdeptdetailService.updateInputdeptdetail(detail);
									}
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
							salesdept.setDatadictByBranch(flowtemplatedetail.getDatadictByBranch());
							for(Salesdeptdetail detail : (Set<Salesdeptdetail>)salesdept.getSalesdeptdetails()) {
								//根据明细子卡类型获取相应模版的分支第一步
								Cardsubtype subtype = detail.getCardsubtype();
								for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()) {
									if(subtype.equals(branch.getCardsubtype()) &&  branch.getBranchseq() == 1) {
										detail.setFlowtemplatebranch(branch);
										salesdeptdetailService.updateSalesdeptdetail(detail);
									}
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
								exitdept.setDatadictByBranch(flowtemplatedetail.getDatadictByBranch());
							for(Exitdeptdetail detail : (Set<Exitdeptdetail>)exitdept.getExitdeptdetails()) {
								//根据明细子卡类型获取相应模版的分支第一步
								Cardsubtype subtype = detail.getCardsubtype();
								for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)flowtemplatedetail.getFlowtemplatebranchs()) {
									if(subtype.equals(branch.getCardsubtype()) &&  branch.getBranchseq() == 1) {
										detail.setFlowtemplatebranch(branch);
										exitdeptdetailService.updateExitdetailno(detail);
									}
								}
							}
						}
					}
					//取消审核完成后自动生成、采取手动形式（待定）
					if("完成".equals(flowtemplatedetail.getDatadictByWorkflowstatusno().getName())) {
						if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {//flowflag由页面传进
							//执行自动生成出库单（不可行，需选卡）
						}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
							//执行自动卡信息过户 outputcard表中
							for(Outputdeptdetail opd: (Set<Outputdeptdetail>)outputdept.getOutputdeptdetails()){
								//get cardno
								List<Outputcard> opcl = outputcardService.findAllOutputcardByOutdetailno(opd.getOutdetailno());
								for(Outputcard opc : opcl){
									Cardinfo cardinfo = cardinfoService.findCardinfo(opc.getCardno());
									Datadict dictByStatus = new Datadict();
									//置卡状态为库存状态  76l
									datadictByStatus.setTypeid(StringToken.DICT_CARDSTATUS_STORE);
									cardinfo.setDatadictByStatus(dictByStatus);
									cardinfo.setBelongto("");
									cardinfo.setDepartment(department);//当前部门
									cardinfoService.updateCardinfo(cardinfo);
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
							//执行自动卡信息过户 inputcard表中
							for(Inputdeptdetail ipd: (Set<Inputdeptdetail>)inputdept.getInputdeptdetails()){
								//get cardno
								List<Inputcard> ipcl = inputcardService.findAllInputcardByIntdetailno(ipd.getIntdetailno());
								for(Inputcard ipc : ipcl){
									Cardinfo cardinfo = cardinfoService.findCardinfo(ipc.getCardno());
									Datadict dictByStatus = new Datadict();
									//置卡状态为库存状态  76l
									datadictByStatus.setTypeid(StringToken.DICT_CARDSTATUS_STORE);
									cardinfo.setDatadictByStatus(dictByStatus);
									cardinfo.setBelongto("");
									cardinfo.setDepartment(department);//当前部门
									cardinfoService.updateCardinfo(cardinfo);
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
							//执行自动卡信息过户 
							for(Exitdeptdetail epd: (Set<Exitdeptdetail>)exitdept.getExitdeptdetails()){
								//get cardno
								List<Exitcard> ecl = exitcardService.findAllExitcardByExitdetailno(epd.getExitdetailno());
								for(Exitcard ec : ecl){
									Cardinfo cardinfo = cardinfoService.findCardinfo(ec.getCardno());
									Datadict dictByStatus = new Datadict();
									//置卡状态为库存状态  76l
									datadictByStatus.setTypeid(StringToken.DICT_CARDSTATUS_STORE);
									cardinfo.setDatadictByStatus(dictByStatus);
									cardinfo.setBelongto("");
									cardinfo.setDepartment(department);//当前部门
									cardinfoService.updateCardinfo(cardinfo);
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
							//执行自动卡信息过户 
							for(Salesdeptdetail spd: (Set<Salesdeptdetail>)salesdept.getSalesdeptdetails()){
								//get cardno
								List<Salescard> scl = salescardService.findAllSalescardWithSalesdetailno(spd.getSalesdetailno());
								for(Salescard sc : scl){
									Cardinfo cardinfo = cardinfoService.findCardinfo(sc.getCardno());
									Datadict dictByStatus = new Datadict();
									//置卡状态为库存状态  76l
									datadictByStatus.setTypeid(StringToken.DICT_CARDSTATUS_STORE);
									cardinfo.setDatadictByStatus(dictByStatus);
									cardinfo.setBelongto("");
									cardinfo.setDepartment(department);//当前部门
									cardinfoService.updateCardinfo(cardinfo);
								}
							}
						}
					}
				}
				else {
					if(1 == flowtemplatedetail.getSeq()) {
						Datadict dict_status = new Datadict();
						dict_status.setTypeid(StringToken.DICT_WORK_STATUS_CANCEL);//作废状态
						datadictByStatus = dict_status;
						
						//修改卡信息状态；撤销等等 
						if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {//flowflag由页面传进
							//执行自动生成出库单（不可行，需选卡）
						}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
							//执行自动卡信息过户 outputcard表中
							for(Outputdeptdetail opd: (Set<Outputdeptdetail>)outputdept.getOutputdeptdetails()){
								//get cardno
								List<Outputcard> opcl = outputcardService.findAllOutputcardByOutdetailno(opd.getOutdetailno());
								for(Outputcard opc : opcl){
									Cardinfo cardinfo = cardinfoService.findCardinfo(opc.getCardno());
									Datadict dictByStatus = new Datadict();
									//置卡状态为库存状态  76l
									datadictByStatus.setTypeid(StringToken.DICT_CARDSTATUS_STORE);
									cardinfo.setDatadictByStatus(dictByStatus);
									cardinfo.setBelongto("");
									cardinfoService.updateCardinfo(cardinfo);
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
							//执行自动卡信息过户 inputcard表中
							for(Inputdeptdetail ipd: (Set<Inputdeptdetail>)inputdept.getInputdeptdetails()){
								//get cardno
								List<Inputcard> ipcl = inputcardService.findAllInputcardByIntdetailno(ipd.getIntdetailno());
								for(Inputcard ipc : ipcl){
									Cardinfo cardinfo = cardinfoService.findCardinfo(ipc.getCardno());
									Datadict dictByStatus = new Datadict();
									//置卡状态为初始状态  71l
									datadictByStatus.setTypeid(StringToken.DICT_CARDSTATUS_INIT);
									cardinfo.setDatadictByStatus(dictByStatus);
									cardinfo.setBelongto("");
									cardinfoService.updateCardinfo(cardinfo);
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
							//执行自动卡信息过户 
							for(Salesdeptdetail spd: (Set<Salesdeptdetail>)salesdept.getSalesdeptdetails()){
								//get cardno
								List<Salescard> spcl = salescardService.findAllSalescardWithSalesdetailno(spd.getSalesdetailno());
								for(Salescard spc : spcl){
									Cardinfo cardinfo = cardinfoService.findCardinfo(spc.getCardno());
									Datadict dictByStatus = new Datadict();
									//置卡状态为库存状态  76l
									datadictByStatus.setTypeid(StringToken.DICT_CARDSTATUS_STORE);
									cardinfo.setDatadictByStatus(dictByStatus);
									cardinfo.setBelongto("");
									cardinfoService.updateCardinfo(cardinfo);
								}
							}
						}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
							//执行自动卡信息过户 
							for(Exitdeptdetail epd: (Set<Exitdeptdetail>)exitdept.getExitdeptdetails()){
								//get cardno
								List<Exitcard> epcl = exitcardService.findAllExitcardByExitdetailno(epd.getExitdetailno());
								for(Exitcard epc : epcl){
									Cardinfo cardinfo = cardinfoService.findCardinfo(epc.getCardno());
									Datadict dictByStatus = new Datadict();
									//置卡状态为库存状态  76l
									datadictByStatus.setTypeid(StringToken.DICT_CARDSTATUS_STORE);
									cardinfo.setDatadictByStatus(dictByStatus);
									cardinfo.setBelongto("");
									cardinfoService.updateCardinfo(cardinfo);
								}
							}
						}
					}else {
						//置前一步、状态为回退
						Datadict dict_status = new Datadict();
						dict_status.setTypeid(StringToken.DICT_WORK_STATUS_REFUSE);//回退状态
						datadictByStatus = dict_status;
						
						if(back != null) {
							curr = back;
							flowaudithistory.setPreseq(flowtemplatedetail.getSeq());
							
							if(StringToken.DICT_FLOWBRANCH_YES.equals(back.getDatadictByBranch().getName())) {
								flowaudithistory.setPreseq(flowtemplatedetail.getSeq());
								datadictByBranch = back.getDatadictByBranch();
								
								//修改单子获取子单 修改其模版分支
								if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {//flowflag由页面传进
									applydept.setDatadictByBranch(back.getDatadictByBranch());
									//修改报领明细表模版分支
									for(Applydeptdetail detail : (Set<Applydeptdetail>)applydept.getApplydeptdetails()) {
										//根据明细子卡类型获取相应模版的分支最大步骤
										Cardsubtype subtype = detail.getCardsubtype();
										for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)back.getFlowtemplatebranchs()) {
											if(subtype.equals(branch.getCardsubtype())) {
												if(branch.getBranchseq() == 1) {
													detail.setFlowtemplatebranch(branch);
												}
												
												if(branch.getBranchseq() > detail.getFlowtemplatebranch().getBranchseq()){
													detail.setFlowtemplatebranch(branch);
												}
												
												applydeptdetailService.updateApplydeptdetail(detail);
											}
										}
									}
								}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
									outputdept.setDatadictByBranch(back.getDatadictByBranch());
//										修改出库明细表模版分支
									for(Outputdeptdetail detail : (Set<Outputdeptdetail>)outputdept.getOutputdeptdetails()) {
										//根据明细子卡类型获取相应模版的分支最大步骤
										Cardsubtype subtype = detail.getCardsubtype();
										for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)back.getFlowtemplatebranchs()) {
											if(subtype.equals(branch.getCardsubtype())) {
												if(branch.getBranchseq() == 1) {
													detail.setFlowtemplatebranch(branch);
												}
												
												if(branch.getBranchseq() > detail.getFlowtemplatebranch().getBranchseq()){
													detail.setFlowtemplatebranch(branch);
												}
												outputdeptdetailService.updateOutputdeptdetail(detail);
											}
										}
									}
								}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
									inputdept.setDatadictByBranch(back.getDatadictByBranch());
//										修改入库明细表模版分支
									for(Inputdeptdetail detail : (Set<Inputdeptdetail>)inputdept.getInputdeptdetails()) {
										//根据明细子卡类型获取相应模版的分支最大步骤
										Cardsubtype subtype = detail.getCardsubtype();
										for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)back.getFlowtemplatebranchs()) {
											if(subtype.equals(branch.getCardsubtype())) {
												if(branch.getBranchseq() == 1) {
													detail.setFlowtemplatebranch(branch);
												}
												
												if(branch.getBranchseq() > detail.getFlowtemplatebranch().getBranchseq()){
													detail.setFlowtemplatebranch(branch);
												}
												inputdeptdetailService.updateInputdeptdetail(detail);
											}
										}
									}
								}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
									exitdept.setDatadictByBranch(back.getDatadictByBranch());
//									修改出库明细表模版分支
									for(Exitdeptdetail detail : (Set<Exitdeptdetail>)exitdept.getExitdeptdetails()) {
										//根据明细子卡类型获取相应模版的分支最大步骤
										Cardsubtype subtype = detail.getCardsubtype();
										for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)back.getFlowtemplatebranchs()) {
											if(subtype.equals(branch.getCardsubtype())) {
												if(branch.getBranchseq() == 1) {
													detail.setFlowtemplatebranch(branch);
												}
												
												if(branch.getBranchseq() > detail.getFlowtemplatebranch().getBranchseq()){
													detail.setFlowtemplatebranch(branch);
												}
												exitdeptdetailService.updateExitdetailno(detail);
											}
										}
									}
								}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
									salesdept.setDatadictByBranch(back.getDatadictByBranch());
//									修改出库明细表模版分支
									for(Salesdeptdetail detail : (Set<Salesdeptdetail>)salesdept.getSalesdeptdetails()) {
										//根据明细子卡类型获取相应模版的分支最大步骤
										Cardsubtype subtype = detail.getCardsubtype();
										for(Flowtemplatebranch branch : (Set<Flowtemplatebranch>)back.getFlowtemplatebranchs()) {
											if(subtype.equals(branch.getCardsubtype())) {
												if(branch.getBranchseq() == 1) {
													detail.setFlowtemplatebranch(branch);
												}
												
												if(branch.getBranchseq() > detail.getFlowtemplatebranch().getBranchseq()){
													detail.setFlowtemplatebranch(branch);
												}
												salesdeptdetailService.updateSalesdeptdetail(detail);
											}
										}
									}
								}
							}
						}
					}
					datadictByResultno.setTypeid(StringToken.DICT_FLOWRESULT_F);
				}
				
				if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {//flowflag由页面传进
					applydept.setDatadictByStatus(datadictByStatus);
					applydept.setFlowtemplatedetail(curr);
					applydeptService.updateApplydept(applydept);//需判断flowflag
				}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
					outputdept.setDatadictByStatus(datadictByStatus);
					outputdept.setFlowtemplatedetail(curr);
					outputdeptService.updateOutputdept(outputdept);
				}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
					inputdept.setDatadictByStatus(datadictByStatus);
					inputdept.setFlowtemplatedetail(curr);
					inputdeptService.updateInputdept(inputdept);
				}else if(StringToken.DICT_FLOWFLAG_SALESDEPT == flowflag) {
					salesdept.setDatadictByStatus(datadictByStatus);
					salesdept.setFlowtemplatedetail(curr);
					salesdeptService.updateSalesdept(salesdept);
				}else if(StringToken.DICT_FLOWFLAG_EXITDEPT == flowflag) {
					exitdept.setDatadictByStatus(datadictByStatus);
					exitdept.setFlowtemplatedetail(curr);
					exitdeptService.updateExitdept(exitdept);
				}
				
			}//end branch
			
//			保存审核记录
			flowaudithistory.setAuditdate(new Date());//审核时间
			flowaudithistory.setDatadictByBranch(datadictByBranch);//分支标识
			flowaudithistory.setDatadictByFlowflagno(flowworkitem.getDatadictByFlag());//流程标识
			flowaudithistory.setDatadictByFlowstatusno(datadictByStatus);//流程状态
			flowaudithistory.setFlowno(flowno);//单号
			flowaudithistory.setSeq(flowtemplatedetail.getSeq());//审核步骤
			//flowaudithistory.setPreseq(flowtemplatedetail.getSeq());//前一步骤处理不好
			flowaudithistory.setPersonnel(personnel);//操作人
			flowaudithistory.setRule(rule);//操作人相应的角色权限
			flowaudithistory.setDatadictByResultno(datadictByResultno);//审核结果：关联到字典
			
			flowaudithistoryService.addFlowaudithistory(flowaudithistory);
			//执行审核历史的存储操作
			
		}//end checked!	
			
		return SUCCESS;
	}
	
	public String findAllFlowaudithistory() throws Exception {
		pm = flowaudithistoryService.findFlowaudithistoryForPager();
		return SUCCESS;
	}
	
	public String findAllFlowaudithistoryWithParam() throws Exception {
		pm = flowaudithistoryService.findFlowaudithistoryForPager(flowflag,flowno);
		return SUCCESS;
	}
	
	public String findAllFlowaudithistoryForCase() throws Exception {
		Applydept applydept = null;
		Outputdept outputdept = null;
		Inputdept inputdept = null;
		if(StringToken.DICT_FLOWFLAG_APPLYDEPT == flowflag) {//flowflag由页面传进
			applydept = applydeptService.findApplydept(flowno);
			flowworkitem = applydept.getFlowworkitem();//获得与单子对应的模版
		}else if(StringToken.DICT_FLOWFLAG_OUTPUTDEPT == flowflag) {
			outputdept = outputdeptService.findOutputdept(flowno);
			flowworkitem = outputdept.getFlowworkitem();
		}else if(StringToken.DICT_FLOWFLAG_INPUTDEPT == flowflag) {
			inputdept = inputdeptService.findInputdept(flowno);
			flowworkitem = inputdept.getFlowworkitem();
		}
		return SUCCESS;
	}
	
	public String findFlowaudithistory() throws Exception {
		flowaudithistory = flowaudithistoryService.findFlowaudithistory(flowid);
		return SUCCESS;
	}
	
	public String delFlowaudithistory() throws Exception {
		flowaudithistoryService.removeFlowaudithistory(flowid);
		return SUCCESS;
	}

	/**
	 * @return the flowaudithistory
	 */
	public Flowaudithistory getFlowaudithistory() {
		return flowaudithistory;
	}

	/**
	 * @param flowaudithistory the flowaudithistory to set
	 */
	public void setFlowaudithistory(Flowaudithistory flowaudithistory) {
		this.flowaudithistory = flowaudithistory;
	}

	/**
	 * @return the flowaudithistoryService
	 */
	public FlowaudithistoryService getFlowaudithistoryService() {
		return flowaudithistoryService;
	}

	/**
	 * @param flowaudithistoryService the flowaudithistoryService to set
	 */
	public void setFlowaudithistoryService(
			FlowaudithistoryService flowaudithistoryService) {
		this.flowaudithistoryService = flowaudithistoryService;
	}

	/**
	 * @return the flowid
	 */
	public String getFlowid() {
		return flowid;
	}

	/**
	 * @param flowid the flowid to set
	 */
	public void setFlowid(String flowid) {
		this.flowid = flowid;
	}

	/**
	 * @return the pm
	 */
	public PagerModel getPm() {
		return pm;
	}

	/**
	 * @param pm the pm to set
	 */
	public void setPm(PagerModel pm) {
		this.pm = pm;
	}

	/**
	 * @return the applydeptdetailService
	 */
	public ApplydeptdetailService getApplydeptdetailService() {
		return applydeptdetailService;
	}

	/**
	 * @param applydeptdetailService the applydeptdetailService to set
	 */
	public void setApplydeptdetailService(
			ApplydeptdetailService applydeptdetailService) {
		this.applydeptdetailService = applydeptdetailService;
	}

	/**
	 * @return the applydeptService
	 */
	public ApplydeptService getApplydeptService() {
		return applydeptService;
	}

	/**
	 * @param applydeptService the applydeptService to set
	 */
	public void setApplydeptService(ApplydeptService applydeptService) {
		this.applydeptService = applydeptService;
	}

	public long getFlowflag() {
		return flowflag;
	}

	public void setFlowflag(long flowflag) {
		this.flowflag = flowflag;
	}

	/**
	 * @return the flowno
	 */
	public String getFlowno() {
		return flowno;
	}

	/**
	 * @param flowno the flowno to set
	 */
	public void setFlowno(String flowno) {
		this.flowno = flowno;
	}

	/**
	 * @return the permissionService
	 */
	public PermissionService getPermissionService() {
		return permissionService;
	}

	/**
	 * @param permissionService the permissionService to set
	 */
	public void setPermissionService(PermissionService permissionService) {
		this.permissionService = permissionService;
	}

	/**
	 * @return the result
	 */
	public String getResult() {
		return result;
	}

	/**
	 * @param result the result to set
	 */
	public void setResult(String result) {
		this.result = result;
	}

	/**
	 * @return the inputdeptdetailService
	 */
	public InputdeptdetailService getInputdeptdetailService() {
		return inputdeptdetailService;
	}

	/**
	 * @param inputdeptdetailService the inputdeptdetailService to set
	 */
	public void setInputdeptdetailService(
			InputdeptdetailService inputdeptdetailService) {
		this.inputdeptdetailService = inputdeptdetailService;
	}

	/**
	 * @return the inputdeptService
	 */
	public InputdeptService getInputdeptService() {
		return inputdeptService;
	}

	/**
	 * @param inputdeptService the inputdeptService to set
	 */
	public void setInputdeptService(InputdeptService inputdeptService) {
		this.inputdeptService = inputdeptService;
	}

	/**
	 * @return the outputdeptdetailService
	 */
	public OutputdeptdetailService getOutputdeptdetailService() {
		return outputdeptdetailService;
	}

	/**
	 * @param outputdeptdetailService the outputdeptdetailService to set
	 */
	public void setOutputdeptdetailService(
			OutputdeptdetailService outputdeptdetailService) {
		this.outputdeptdetailService = outputdeptdetailService;
	}

	/**
	 * @return the outputdeptService
	 */
	public OutputdeptService getOutputdeptService() {
		return outputdeptService;
	}

	/**
	 * @param outputdeptService the outputdeptService to set
	 */
	public void setOutputdeptService(OutputdeptService outputdeptService) {
		this.outputdeptService = outputdeptService;
	}

	/**
	 * @return the flowworkitem
	 */
	public Flowworkitem getFlowworkitem() {
		return flowworkitem;
	}

	/**
	 * @param flowworkitem the flowworkitem to set
	 */
	public void setFlowworkitem(Flowworkitem flowworkitem) {
		this.flowworkitem = flowworkitem;
	}

	/**
	 * @return the branchno
	 */
	public String getBranchno() {
		return branchno;
	}

	/**
	 * @param branchno the branchno to set
	 */
	public void setBranchno(String branchno) {
		this.branchno = branchno;
	}

	/**
	 * @return the dictbranch
	 */
	public String getDictbranch() {
		return dictbranch;
	}

	/**
	 * @param dictbranch the dictbranch to set
	 */
	public void setDictbranch(String dictbranch) {
		this.dictbranch = dictbranch;
	}

	/**
	 * @return the inputcardService
	 */
	public InputcardService getInputcardService() {
		return inputcardService;
	}

	/**
	 * @param inputcardService the inputcardService to set
	 */
	public void setInputcardService(InputcardService inputcardService) {
		this.inputcardService = inputcardService;
	}

	/**
	 * @return the outputcardService
	 */
	public OutputcardService getOutputcardService() {
		return outputcardService;
	}

	/**
	 * @param outputcardService the outputcardService to set
	 */
	public void setOutputcardService(OutputcardService outputcardService) {
		this.outputcardService = outputcardService;
	}
}
